import QtQuick 2.12
import QtGraphicalEffects 1.14

// 顶部消息提示弹窗

Item {
    id: root

    property int idx: 0
    property int type: 0        // 0: 正确  1: 错误  2: 警告  3: 其它
    property string text: ""

    height: 66*dp
    width:  parent.width

    opacity: 0.95


    signal close()

    Rectangle{
        radius: 3*dp
        anchors.fill: parent
        Row{
            y: 12*dp; x: 15*dp
            height: 16*dp; width: parent.width - 30*dp
            spacing: 10*dp
            CustomImage{
                height: 16*dp
                width: 16*dp
                source: type===0 ? "qrc:/picture/msgSuccess.png" : (type===1 ? "qrc:/picture/msgError.png" : "qrc:/picture/msgWarning.png")
                anchors.verticalCenter: parent.verticalCenter
            }
            Text{
                text: type===0 ? "成功" : (type===1 ? "错误" : (type===2 ? "警告" : "提示"))
                font.pixelSize: config.fontsize
                font.bold: true
                anchors.verticalCenter: parent.verticalCenter
            }
        }


        Item{
            height: 28*dp; width: parent.width - 80*dp
            x: 40*dp; y: 34*dp
            Text {
                anchors.verticalCenter: parent.verticalCenter
                text: root.text
                font.pixelSize: config.fontsize
                color: "#999999"
            }
        }

        CustomButton{
            button_color: "transparent"
            title: "X"
            height: 36*dp
            width: 30*dp
            text_color: "#CCCCCC"
            x: parent.width - 40*dp; y: 5*dp

            onReleased: {
                close()
            }
        }
    }
    // 阴影
    layer.enabled: true
    layer.effect: DropShadow {
        radius: 12*dp
        samples: 43
        transparentBorder: true
        color: "#26666666"
        opacity: 0.3
    }

}
